<template>
  <div>
    <el-select v-model="value" placeholder="请选择">
      <el-option
        v-for="item in UserRole"
        :key="item.roleId"
        :label="item.roleName"
        :value="item.roleId"
      >
      </el-option>
    </el-select>
  </div>
</template>
<script>
import { RoleShow, AddUserRoles } from "@/api/admin";
export default {
  data() {
    return {
      UserRole: [],
      value: "",
    };
  },
  methods: {
    getsho(id) {
      RoleShow().then((res) => {
        this.UserRole = res.data;
      });
      this.userId=id;
    },
    postUserRole() {
      let from = {
        userId: this.userId,
        roleId: this.value,
      };
      AddUserRoles(from).then((res) => {
        if (res.data) {
          this.$message.success("添加成功");
        }
      });
    },
  },
  created() {
    this.getsho();
  },
};
</script>
<style >
</style>